package cn.itsource.basic.domain;

import cn.hutool.crypto.digest.MD5;

import java.util.Random;

public interface CreatePassword {

    String getSalt();

    void setSalt(String salt);

    String getPassword();

    void setPassword(String password);

    default void init() {
        //1.1生成盐值 hutool的
        String salt = String.valueOf(new Random().nextInt(50));
        //1.2生成加密字符串
        String pwd = MD5.create().setSalt(salt.getBytes()).digestHex(this.getPassword());

        this.setSalt(salt);
        this.setPassword(pwd);
    }

}
